import router from '@system.router';
import prompt from '@ohos.prompt'
import {changePreState} from '../../common/utils/changePreState';
export default {
    data: {
        curPrescription:{},
        title: "",
        medInfoList:[
            {
                name:'A药',
                useNum:"10g",
                useType:"内服",
                num:"25片"
            },
            {
                name:'B药',
                useNum:"18g",
                useType:"外服",
                num:"666片"
            },
            {
                name:'D药',
                useNum:"18g",
                useType:"外服",
                num:"666片"
            }
        ]
    },
    onInit() {
        console.log("xxx---切换:"+JSON.stringify(this.curPrescription))

    },
    back(){
        router.back();
    },
    confirm(){
        let ID = this.curPrescription.ID;
        changePreState(ID,"配送中",(res)=>{
            console.log("xxx---更改订单状态结果：  "+ res)
        })
        this.back();
    },
    showDialog() {
        let that = this;
        prompt.showDialog({
            title: '',
            message: '请再次确认药物是否装填完毕',
            buttons: [
                {
                    text: '确认',
                    color: '#000000',
                },
                {
                    text: '取消',
                    color: '#000000',
                }
            ],
        })
            .then(data => {
                console.info('showDialog success, click button: ' + data.index);
                let index = data.index
                if(index==0){
                    that.confirm();
                }
            })
            .catch(err => {
                console.info('showDialog error: ' + err);
            })
    }
}
